<template name="sendcar">
	<!--  查询已录入的盘点单列表  已盘点的数据列表  -->
	<view class="mypage">
		<view class="cu-bar search bg-white">
			<view class="search-form round">
				<text class="cuIcon-search"></text>
				<input type="text" placeholder="输入单号" v-model="keyword"></input>
			</view>
			<view class="action">
				<button class="cu-btn bg-blue shadow-blur round" @tap="handelSearch">搜索</button>
			</view>
		</view>
		
		<view class="card-list-wrapper">
			<view class="card-list-row radius shadow-warp bg-white margin-top" 
			v-for="(item,index) in planList" :key="index" 
			>
				
				<view class="flex-just-between bottom-border top-wrap">
					<text class="text-blue text-bold">盘点单号：{{ item.BILLNO }}</text>
					<view class="cu-capsule radius">
						<view class='cu-tag bg-blue sm'>
							<text class='cuIcon-medal'></text>
						</view>
						<view class="cu-tag line-brown sm">
							{{ index+1}}
						</view>
					</view>
				</view>
				
				<view class="card-list-row-1">
					<text>集团：{{ item.GROUPNAME || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text>组织：{{ item.ORGNAME || '' }}</text>
				</view>
				<!-- <view class="card-list-row-1">
					<text class="cuIcon-title text-red"></text>
					<text>厂区：{{ item.ORGNAME || '' }}</text>
				</view> -->
				<!-- <view class="card-list-row-1">
					<text>仓库：{{ item.STORENAME || '' }}</text>
				</view> -->
				<view class="card-list-row-1">
					<text>位置：{{ item.STATIONNAME || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<view >
						状态：
						<text :class="item.BILLSTATUS==1?'text-blue':'text-red' ">
						{{  item.BILLSTATUS==1?'已审核':'未审核' }}
						</text>
					</view>
				</view>
				<view class="card-list-row-1">
					<text>盘点人：{{ item.INVER || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<view >
						是否完成：
						<text :class="item.ISFINISH==1?'text-blue':'text-red' ">
						{{  item.ISFINISH==1?'已完成':'未完成' }}
						</text>
					</view>
				</view>
				
				<view class="flex-just-between top-border margin-top btn-wrap">
					<button class="cu-btn round lines-blue" v-if="item.ISFINISH!=1" @click="openDetail(item,1)">继续盘点</button>
					<button class="cu-btn round lines-blue" @click="openDetail(item,2)">所有盘点明细</button>
					<button class="cu-btn round lines-blue" @click="openDetail(item,3)">已盘点明细</button>
				</view>
			</view>
		
		</view>
		
	</view>

</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import api from '@/common/api.js';
	import utils from '@/common/util.js';
	let query = {
			"category":"ST_INVENTORY",
			"page":1,
			"rows":"10",
			"sidx":"",
			"sord":"desc",
			"queryJson": "" ,
			"userId": "",
			"account": "admin"
	},
	// queryJson = { BILLSTATUS:1} ;
	queryJson = { } ;
	let _self,page=1, total=1 ;
	
	export default {
		computed: mapState(['userInfo','baseUrl']),
		data() {
			return {
				title:'列表',
				planList: [] ,
				keyword:''
			};
		},
		onLoad(params) {
			_self = this 
			_self.title = params.n + '列表'
			query.userId = _self.userInfo.UserId ;
			query.account= _self.userInfo.Account;
			
			queryJson = {}
			getApp().globalData.queryJsonLS = null
			// console.log(params);
			page = 1;
			total = 1 ;
			_self.getNewsList();
		},
		onNavigationBarButtonTap(e) {
			this.listenOnce()
			uni.navigateTo({
				url: '/pages/public/query?type=menu1010' 
			})
		},
		//下拉刷新
		onPullDownRefresh : function(){
			// 重置分页及数据
			page = 1;
			total = 1 ;
			_self.planList = []
			this.getNewsList();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
			utils.tips("数据已刷新");
		},
		// 加载更多
		onReachBottom : function(){
			this.getNewsList();
		},
		methods:{
			...mapMutations(['setCheckOrder']),
			openDetail:function(e,type){
				// console.log(e);
				// _self.setCheckOrder([_self.planList[e]]);
				let id = e.BILLNO ;
				let paths = type==1?'mater-list?no=1&id='+id : 'mater_list_over?id='+id+'&t='+type;
				uni.navigateTo({
					url: paths
				})
			},
			// 初始监听
			listenOnce() {
				uni.$off('reload')
				uni.$once("reload", function(data) {
					queryJson= { ...queryJson , ...data }
					getApp().globalData.queryJsonLS = queryJson
					_self.handelSearch()
				});
			},
			
			handelSearch() {
				queryJson.BILLNO = _self.keyword;
				page = 1;
				total = 1;
				_self.planList = [];
				this.getNewsList();
			},
			
			// apiPublic.getOrderList
			getNewsList(){
				// console.log(page , total);
				if (page > total) {
				  return utils.tips("没有数据了");
				}
				// queryJson.BILLNO = _self.keyword;
				query.page = page ;
				query.queryJson = JSON.stringify(queryJson);
				// console.log(query);
				let URL  =  api.apiPublic.overCheckList ;
				this.axios({
					url: URL ,
					data: query ,
					isLoading: 1
				}).then(res=>{
					let { Result } = res ;
					// console.log(Result);
					total = Result.total
					page++
					_self.planList = [..._self.planList,...Result.rows] 
					utils.setPageTitle('盘点单列表(' + Result.records + ')')
				})
			},
		}
	}
</script>

<style scoped>
	
	.card-list-wrapper {
		width: 710upx;
		height: 100upx;
		margin: 0 auto;
		
	}
	
	.cu-btn{
		font-size: 30rpx!important;
	}

	.card-list-row {
		padding: 20upx;
	}

	.card-list-row-1 {
		padding: 10upx 0;
	}
	.top-border{
		border-top: 1upx solid rgba(0,0,0,.1);
	}
	.top-wrap{
		padding-bottom: 20upx;
		margin-bottom: 20upx;
	}
	.bottom-border{
		border-bottom: 1upx solid rgba(0,0,0,.1);
	}
	.btn-wrap{
		padding-top: 20upx;
	}
</style>
